from pages.basePage3 import BasePage
from config.setting import host_port
from selenium.webdriver.common.action_chains import ActionChains
class Elment_Rob_tenant(BasePage):
    def __init__(self):
        BasePage.__init__(self)
        self.driver.get(f"http://{host_port}/SharedParkingPlace/property/index.html")

    # 定位层
    # 定位用户管理
    def elment_yonghuguanli(self):
        return self.driver.find_element_by_xpath('//div[@id="main"]/div[1]/div[1]/div[1]/div[1]')
    # 定位抢租客信息模块
    def elment_qiangzuke(self):
        return self.driver.find_element_by_xpath('//div[@id="_easyui_tree_3"]/span[3]')
    # 定位表单
    def elment_biaodan(self):
        a=self.driver.find_element_by_xpath('//div[@id="testIframe"]/div[2]/div[2]/div/iframe')
        return a
    # 定位查询类型框
    def elment_chaxun_types(self):
        return self.driver.find_element_by_xpath('//span[@class="textbox easyui-fluid searchbox"]/a')

        # 定位查询类型
    def elment_chaxun_type(self):
        return self.driver.find_element_by_xpath('//*[@id="mm"]/div[3]/div')
    # 定位输入框
    def elment_input(self):
        return self.driver.find_element_by_xpath('//span[@class="textbox easyui-fluid searchbox"]/input[1]')
    # 定位查询按钮
    def elment_chaxun(self):
        return self.driver.find_element_by_xpath('//*[@id="tb"]/span/span')
    # 定位文本框
    def elment_text(self):
        return self.driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[2]/div[2]')
class Operate_Rob_tenant(Elment_Rob_tenant):
    # 操作层
    def __init__(self):
        Elment_Rob_tenant.__init__(self)
    # 点击用户管理
    def click_yonghuguanli(self):
        self.elment_yonghuguanli().click()
    #     点击抢租客
    def click_qiangzuke(self):
        self.elment_qiangzuke().click()
    # 切换表单
    def get_biaodan(self):
        c=self.elment_biaodan()
        return self.driver.switch_to.frame(c)
    # # 设置鼠标悬停
    def xuanting(self):
        return ActionChains(self.driver).move_to_element(self.elment_chaxun_types()).perform()  # 悬停
    # 点击查询类型
    def click_caxun_type(self):
        self.elment_chaxun_type().click()
    # 输入信息
    def input_chaxun(self):
        return self.elment_input().send_keys("13379439815")
    # 点击查询按钮
    def click_chaxun(self):
        self.elment_chaxun().click()

    # 获取文本框内容
    def text_yemian(self):
        return self.elment_text().text
class  Apply_Rob_tenant(Operate_Rob_tenant):
    # 应用层
    def __init__(self):
        Operate_Rob_tenant.__init__(self)
    def order1(self):
        self.click_yonghuguanli()
        self.click_qiangzuke()
        self.get_biaodan()
        self.xuanting()
        self.click_caxun_type()
        self.input_chaxun()
        self.click_chaxun()
        b=self.text_yemian()

        return b
if __name__ == '__main__':
    Apply_Rob_tenant().order1()